<?php 
function connect(){
	define('DB_HOST', 'localhost');
	define('DB_USER', 'root');
	define('DB_PWD', '');
	define('DB_CHARSET', 'UTF8');
	define('DB_DBNAME', 'neu-video');
	//连接mysql
	$link=@mysql_connect(DB_HOST,DB_USER,DB_PWD) or die ('数据库连接失败<br/>ERROR '.mysql_errno().':'.mysql_error());
	//设置字符集
	mysql_set_charset(DB_CHARSET);
	//打开指定的数据库
	mysql_select_db(DB_DBNAME) or die('指定的数据库打开失败'.mysql_error());
	return $link; 
}
/*function delete($st1,$key=null,$value=null){
$key=$key==null?'':'where'.$key."=".$value;*/
function update($tbl,$data,$where=null){
	$sets='';
	foreach ($data as $key => $value) {
		$sets.=$key.="='".$value."',";
	}
	$sets=rtrim($sets,',');
$where=$where==null?'':'where'.$where;
$sql="update  {$tbl} set {sets} {$where}";
$res=mysql_query($sql);
echo $sql;
/*if ($res) {
	return mysql_affected_rows();
	else
		return false;
}*/

}
$result='';
$tbl="videos";
$data=array("vid"=>0,"videoname"=>星球大战,)

  $result = update($tbl,$data,$where);


  /*function add($tbl,$data){
  $keys = implode(',',array_keys($data));
  $values = implode("','", array_values($data));
  $sql="insert into {$tbl}({$keys}) VALUES ('{$values}')";
  $result = mysql_query($sql);
  if($result===FALSE){
    return false;
  }
  else{
    return mysql_insert_id();
  }

}*/
 ?>